<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>
  Class: Agouti::Rack::PackageLimiter::GzipTruncatedStream
  
    &mdash; Documentation by YARD 0.8.7.4
  
</title>

  <link rel="stylesheet" href="../../../css/style.css" type="text/css" charset="utf-8" />

  <link rel="stylesheet" href="../../../css/common.css" type="text/css" charset="utf-8" />

<script type="text/javascript" charset="utf-8">
  hasFrames = window.top.frames.main ? true : false;
  relpath = '../../../';
  framesUrl = "../../../frames.html#!Agouti/Rack/PackageLimiter/GzipTruncatedStream.html";
</script>


  <script type="text/javascript" charset="utf-8" src="../../../js/jquery.js"></script>

  <script type="text/javascript" charset="utf-8" src="../../../js/app.js"></script>


  </head>
  <body>
    <div id="header">
      <div id="menu">
  
    <a href="../../../_index.html">Index (G)</a> &raquo;
    <span class='title'><span class='object_link'><a href="../../../Agouti.html" title="Agouti (module)">Agouti</a></span></span> &raquo; <span class='title'><span class='object_link'><a href="../../Rack.html" title="Agouti::Rack (module)">Rack</a></span></span> &raquo; <span class='title'><span class='object_link'><a href="../PackageLimiter.html" title="Agouti::Rack::PackageLimiter (class)">PackageLimiter</a></span></span>
     &raquo; 
    <span class="title">GzipTruncatedStream</span>
  

  <div class="noframes"><span class="title">(</span><a href="." target="_top">no frames</a><span class="title">)</span></div>
</div>

      <div id="search">
  
    <a class="full_list_link" id="class_list_link"
        href="../../../class_list.html">
      Class List
    </a>
  
    <a class="full_list_link" id="method_list_link"
        href="../../../method_list.html">
      Method List
    </a>
  
    <a class="full_list_link" id="file_list_link"
        href="../../../file_list.html">
      File List
    </a>
  
</div>
      <div class="clear"></div>
    </div>

    <iframe id="search_frame"></iframe>

    <div id="content"><h1>Class: Agouti::Rack::PackageLimiter::GzipTruncatedStream
  
  
  
</h1>

<dl class="box">
  
    <dt class="r1">Inherits:</dt>
    <dd class="r1">
      <span class="inheritName">Rack::Deflater::GzipStream</span>
      
        <ul class="fullTree">
          <li>Object</li>
          
            <li class="next">Rack::Deflater::GzipStream</li>
          
            <li class="next">Agouti::Rack::PackageLimiter::GzipTruncatedStream</li>
          
        </ul>
        <a href="#" class="inheritanceTree">show all</a>
      
      </dd>
    
  
  
    
  
    
  
  
  
    <dt class="r2 last">Defined in:</dt>
    <dd class="r2 last">lib/agouti/rack/package_limiter.rb</dd>
  
</dl>
<div class="clear"></div>

<h2>Overview</h2><div class="docstring">
  <div class="discussion">
    
<p>Public: class responsible for truncating the gzip stream to a given number
of bytes.</p>


  </div>
</div>
<div class="tags">
  

</div>






  
    <h2>
      Instance Method Summary
      <small>(<a href="#" class="summary_toggle">collapse</a>)</small>
    </h2>

    <ul class="summary">
      
        <li class="public ">
  <span class="summary_signature">
    
      <a href="#initialize-instance_method" title="#initialize (instance method)">- (GzipTruncatedStream) <strong>initialize</strong>(body, mtime, byte_limit) </a>
    

    
  </span>
  
  
    <span class="note title constructor">constructor</span>
  
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'>
<p>Public: Constructor.</p>
</div></span>
  
</li>

      
        <li class="public ">
  <span class="summary_signature">
    
      <a href="#write-instance_method" title="#write (instance method)">- (Object) <strong>write</strong>(data) </a>
    

    
  </span>
  
  
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'>
<p>Public: Writes data to stream.</p>
</div></span>
  
</li>

      
    </ul>
  


  <div id="constructor_details" class="method_details_list">
  <h2>Constructor Details</h2>
  
    <div class="method_details first">
  <h3 class="signature first" id="initialize-instance_method">
  
    - (<tt><span class='object_link'><a href="" title="Agouti::Rack::PackageLimiter::GzipTruncatedStream (class)">GzipTruncatedStream</a></span></tt>) <strong>initialize</strong>(body, mtime, byte_limit) 
  

  

  
</h3><div class="docstring">
  <div class="discussion">
    
<p>Public: Constructor.</p>

<p>body - response body. mtime - last-modified time. byte_limit - byte limit.</p>

<p>Returns an instance of Agouti::Rack::PackageLimiter::GzipTruncatedStream.</p>


  </div>
</div>
<div class="tags">
  

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


106
107
108
109
110</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'lib/agouti/rack/package_limiter.rb', line 106</span>

<span class='kw'>def</span> <span class='id identifier rubyid_initialize'>initialize</span> <span class='id identifier rubyid_body'>body</span><span class='comma'>,</span> <span class='id identifier rubyid_mtime'>mtime</span><span class='comma'>,</span> <span class='id identifier rubyid_byte_limit'>byte_limit</span>
  <span class='kw'>super</span> <span class='id identifier rubyid_body'>body</span><span class='comma'>,</span> <span class='id identifier rubyid_mtime'>mtime</span>
  <span class='ivar'>@byte_limit</span> <span class='op'>=</span> <span class='id identifier rubyid_byte_limit'>byte_limit</span>
  <span class='ivar'>@total_sent_bytes</span> <span class='op'>=</span> <span class='int'>0</span>
<span class='kw'>end</span></pre>
    </td>
  </tr>
</table>
</div>
  
</div>


  <div id="instance_method_details" class="method_details_list">
    <h2>Instance Method Details</h2>

    
      <div class="method_details first">
  <h3 class="signature first" id="write-instance_method">
  
    - (<tt>Object</tt>) <strong>write</strong>(data) 
  

  

  
</h3><div class="docstring">
  <div class="discussion">
    
<p>Public: Writes data to stream.</p>

<p>data - data.</p>

<p>If total sent bytes reaches bytes limit, data is sliced.</p>


  </div>
</div>
<div class="tags">
  

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


117
118
119
120
121
122
123
124</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'lib/agouti/rack/package_limiter.rb', line 117</span>

<span class='kw'>def</span> <span class='id identifier rubyid_write'>write</span><span class='lparen'>(</span><span class='id identifier rubyid_data'>data</span><span class='rparen'>)</span>
  <span class='kw'>if</span> <span class='ivar'>@total_sent_bytes</span> <span class='op'>+</span> <span class='id identifier rubyid_data'>data</span><span class='period'>.</span><span class='id identifier rubyid_bytesize'>bytesize</span> <span class='op'>&gt;</span> <span class='ivar'>@byte_limit</span>
    <span class='id identifier rubyid_data'>data</span> <span class='op'>=</span> <span class='id identifier rubyid_data'>data</span><span class='period'>.</span><span class='id identifier rubyid_byteslice'>byteslice</span><span class='lparen'>(</span><span class='int'>0</span><span class='comma'>,</span> <span class='ivar'>@byte_limit</span> <span class='op'>-</span> <span class='ivar'>@total_sent_bytes</span><span class='rparen'>)</span>
  <span class='kw'>end</span>

  <span class='ivar'>@total_sent_bytes</span> <span class='op'>+=</span> <span class='id identifier rubyid_data'>data</span><span class='period'>.</span><span class='id identifier rubyid_bytesize'>bytesize</span>
  <span class='ivar'>@writer</span><span class='period'>.</span><span class='id identifier rubyid_call'>call</span><span class='lparen'>(</span><span class='id identifier rubyid_data'>data</span><span class='rparen'>)</span>
<span class='kw'>end</span></pre>
    </td>
  </tr>
</table>
</div>
    
  </div>

</div>

    <div id="footer">
  Generated on Tue Sep  2 15:27:50 2014 by
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
  0.8.7.4 (ruby-2.0.0).
</div>

  </body>
</html>